package com.roamer.javase.demo.algorithm;

/**
 * @author roamer
 * @version v1.0
 * @date 2020/10/20 23:44
 */
public class Test {
    static int EMPTY = 1;
    static int PHASE_SHIFT = 32;
    static int PARTIES_SHIFT = 16;

    public static void main(String[] args) {

        int parties = 65535;
        int phase = 0;
        long state = (parties == 0) ? (long) EMPTY : ((long) phase << PHASE_SHIFT) | ((long) parties << PARTIES_SHIFT) | ((long) parties);
        System.out.println(Long.toBinaryString(phase << PHASE_SHIFT));
        System.out.println(Long.toBinaryString(parties >>> PARTIES_SHIFT));
        System.out.println(Long.toBinaryString(parties));
        System.out.println(state);
    }
}
